package com.wan.net.core.client;

import com.wan.net.config.HostAndPort;
import com.wan.net.core.tcp.TcpCodec;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;

import javax.annotation.Nullable;

/**
 * @author wwh
 * @date 2022/6/16 15:12
 */
public class TcpClient extends AbstractClient{
    public TcpClient(HostAndPort host) {
        super(host);
    }

    public TcpClient(HostAndPort hostAndPort, @Nullable ChannelHandler channelHandler) {
        super(hostAndPort, channelHandler);
    }

    public TcpClient(HostAndPort hostAndPort, int idleTimeout) {
        super(hostAndPort, idleTimeout);
    }

    public TcpClient(HostAndPort hostAndPort, int idleTimeout, @Nullable ChannelHandler channelHandler) {
        super(hostAndPort, idleTimeout, channelHandler);
    }

    @Override
    protected void channelChannelInitializer(ChannelPipeline pipeline) {
        pipeline.addLast(new TcpCodec());
    }

    @Override
    public ClientType getClientType() {
        return ClientType.TCP;
    }

    @Override
    protected void onInactive() {
        open();
    }
}
